home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
osclo
/
osclo.c
next >
Wrap
Text File
|
1991-10-18
|
8KB
|
340 lines
/*
EASY OSCILLOSCOPE for GCC 80386 version TOWNS.
プログラムの起動にはTowns-menu上からEXPファイルをクリックしてください。
プログラムの動作には2メガバイトのメモリが必要です(1メガも大丈夫かも)。
Programed by s.kamio June 1991
(Thanks GCC / Thanks TED-ED WINK2)
※ 出来ることならば、低ウエイトモードでの使用をお勧めします。
※ 改造その他は自由に行ってください。
※ スピーカーの音量を上げ過ぎると、まれにハウリングすることがあります。
*/
#include <stdio.h>
#include <tbios.h> /* my header */
#define offset_line 2*60
int fs=639;
int cs=0;
void main (int argc,char *argv[])
begin
int a,i,j,p1,p2,vol,vmap;
j=0; p1=0; p2=256; vol=0; vmap=0;
VGA400_init ();
EGB_zoom (5,5);
EGB_gprint (150,0,"通常速度で表示");
if (argc>1)
{
EGB_cls ();
EGC_putc (11);
EGB_gprint (0,30,"ウエイト落とした");
EGB_gprint (0,30+20,"方が速い時がある");
waite (3*100);
EGB_gprint (150,0,"それなりに高速");
}
for (i=0;i<150;i++)
EGB_roll2 (0,0,400,18,-1,0);
waite (60);
EGB_cls ();
EGB_zoom (1,1);
if (argc>1)
{
EGB_zoom (2,1);
fs=319;
}
SND_init ();
SND_evolumeinit ();
SND_evolume (0,127,127); /* line volume max */
SND_evolume (1,96,96); /* cd volume middle */
SND_mute (0xff);
/* make new screen mode (640*256 / 256 colors) */
outb (0x440,0x0d);
outw (0x442,0x46+offset_line);
outb (0x440,0x0e);
outw (0x442,0x46+512+offset_line);
outb (0x440,0x0f);
outw (0x442,0x46+offset_line);
outb (0x440,0x10);
outw (0x442,0x46+512+offset_line);
for (i=0;i<0x32;i++)
EGB_palette (1,0,i,0,0);
for (i=0;i<256;i++)
EGB_palette (0,i,0x32,i/5,i);
EGB_palette (0,255,255,255,255);
while ((SND_pad(1) & 0x10)!=0)
begin
i=1024*p2/8; /* vram address */
outb (0x440,17);
outw (0x442,i);
outb (0x440,21);
outw (0x442,i);
if ((SND_pad(0) & 0x10)==0)
{
if (fs==639)
{
fs=319;
waite (50);
EGB_zoom (2,1);
}
else
{
fs=639;
waite (50);
EGB_zoom (1,1);
}
}
if ((SND_pad(0) & 0x20)==0)
{
if (cs==0)
{
cs=-1;
waite (50);
}
else
{
cs=0;
waite (50);
}
}
if ((SND_pad(0) & 0x40)==0)
{
main2 ();
}
EGC_linebf256 (0,p1,fs,p1+255,1); /* vram clear */
while ((SND_pad(1) & 0x20)==0) {} /* phase */
vol/=100; /* level meator */
if (vmap<vol) vmap+=(vol-vmap)/4;
vmap+=(vol-vmap)/4;
if (vmap>255) vmap=255;
EGC_linebf256 (0,255-vmap+p1,4*16-1,255+p1,vmap/2);
EGC_linebf256 (fs,255-vmap+p1,fs-4*16+1,255+p1,vmap/2);
outb (0x4e8,0); /* ad converter init */
vol=0;
while ((inpb(0x4e8) & 0x01)==0) {}
j=inpb(0x4e7);
if (cs==0)
{
for(i=0;i<fs;i++)
begin
while ((inpb(0x4e8) & 0x01)==0) {}
a=inpb(0x4e7);
EGC_line256 (i,j+p1,i+1,a+p1,255);
j=a; vol+=abs(a-128);
end
}
else
{
for(i=0;i<fs;i++)
begin
while ((inpb(0x4e8) & 0x01)==0) {}
a=inpb(0x4e7);
EGC_line256 (i,a+p1,i,p1+128,249);
j=a; vol+=abs(a-128);
end
}
i=p1; p1=p2; p2=i;
end
SND_bye ();
for (i=0;i<640;i++)
EGC_line256 (i,0,i,511,0);
for (i=0;i<0x32;i++)
EGB_palette (1,0,0x32-i-1,0,0);
EGB_displaypage (0,0);
VGA400_init ();
EGB_displaypage (0,0);
EGB_pensize (12);
EGB_paintmode (34);
EGB_color (0,230);
EGB_color (2,2+4*1+64*2);
EGB_box (320-220,200-50,320+220,200+50+33);
EGB_writecolor (255);
EGB_gprint (320-220+30,200-50+20,"EASY OSCILLOSCOPE VERSION 1.72");
EGB_gprint (320-50+30,200-50+40,"PROGRAMED BY S.KAMIO 1991");
EGB_gprint (320-220+40,200-50+70+7,"NORMAL MODE : run386 osclo");
EGB_gprint (320-220+40,200-50+90+7,"HIGH SPEED MODE : run386 osclo -h");
EGB_roll (0,-32);
EGB_gprint (200,370,"本日はご利用頂きまして誠に有り難うございました。");
EGB_displaypage (0,1);
if ((SND_pad(2) & 0x10)!=0) waite (100*3);
vram_erase ();
exit (0);
end
main2 ()
{
uint i,j,r;
uint x,y;
int a,b;
int sx[512],sy[512];
int vx[512],vy[512];
unsigned short int p[256];
unsigned short int wep[256*512];
VGA400_init ();
EGB_pensize (12);
EGB_paintmode (34);
EGB_color (0,230);
EGB_color (2,2+4*1+64*2);
EGB_box (320-220,200-16-6,320+220,200+16);
EGB_writecolor (255);
EGB_gprint (130,190,"気違いモード TBIOSで何処まで派手にできるか!?");
EGB_gprint (280,370,"用意の出来るまでしばらくお待ち下さい。");
EGB_gprint (48,32,"みぃたぁなぁー");
EGB_gprint (80,60,"作画が速くても、19.2KHz以上はかけないのだ!");
EGB_gprint (200,230,"なにをやっているか考えてみよう!(簡単なことよ)");
for (j=0;j<512;j++)
{
for (i=0;i<256;i++)
wep[i+j*256]=(random () & 0x7fff) & (1024*3+32*3+3);
}
EGB_init ();
EGB_screen (0,6);
EGB_screen (1,6);
EGB_displaypage (1,3);
EGB_writepage (1);
EGB_zoom (2,2);
EGB_view (256,200);
EGB_displaystart (32,0);
EGB_vramstart (0,2);
EGB_writepage (0);
EGB_zoom (5,5);
EGB_view (128,80);
SPR_init ();
SPR_display (1,1024);
EGB_backcolor (0xffff);
EGB_cls ();
for (i=0;i<256;i++)
{
EGB_writecolor (31*1024+(i % 16)+(i/16)*32);
EGB_pset (i % 16,i / 16);
}
EGB_get (0,0,15,15,&p[0]);
SPR_set (1,1020,1,1,&p[0]);
for (i=0;i<256;i++)
{
EGB_writecolor ((i % 16)+(i/16)*32);
EGB_pset (i % 16,i / 16);
}
EGB_get (0,0,15,15,&p[0]);
for (i=128;i<1020;i+=4)
{
EGB_pset (random () % 256,random () % 512);
SPR_set (1,i,1,1,&p[0]);
}
for (i=0;i<1024;i++)
{
SPR_setposition (0,i,1,1,(i % 16)*16,(i/16)*16);
SPR_attribute (i,1,1,128+(rand () % 223)*4,0);
}
for (i=768;i<1025;i++)
SPR_attribute (i,1,1,1020,0);
SPR_display (1,420);
for (i=0;i<512;i++)
{
vx[i]=0;
while (vx[i]==0)
{
vx[i]=(random () % 14)-7;
}
vy[i]=0;
while (vy[i]==0)
{
vy[i]=(random () % 14)-7;
}
sx[i]=(random () % 256);
sy[i]=(random () % 200);
}
EGB_put (0,0,255,511,&wep[0]);
EGB_displaypage (1,3);
r=rand () % 512;
p[0]=p[255]=0xffff;
EGB_writepage (1);
/* ************************************************** */
while (((SND_pad(0) & 0x80)!=0) && ((SND_pad(1) & 0x10)!=0))
{
/* SPR_display (2,420); */
outb (0x4e8,0); /* ad converter init */
for (i=0;i<256;i++)
{
while ((inpb(0x4e8) & 0x01)==0) {}
j=inpb(0x4e7);
SPR_setposition (0,1023-i,1,1,i-8,j-28-8);
}
for (i=256;i<420;i++)
{
sx[i]=sx[i]+vx[i];
if (sx[i]<0)
sx[i]=255;
if (sx[i]>255)
sx[i]=0;
sy[i]=sy[i]+vy[i];
if (sy[i]<0)
sy[i]=199;
if (sy[i]>199)
sy[i]=0;
SPR_setposition (0,1023-i,1,1,sx[i]-8,sy[i]-8);
}
while ((SND_pad(1) & 0x20)==0)
{
SPR_display (2,420);
for (i=256;i<420;i++)
{
sx[i]=sx[i]+vx[i];
if (sx[i]<0)
sx[i]=255;
if (sx[i]>255)
sx[i]=0;
sy[i]=sy[i]+vy[i];
if (sy[i]<0)
sy[i]=199;
if (sy[i]>199)
sy[i]=0;
SPR_setposition (0,1023-i,1,1,sx[i]-8,sy[i]-8);
}
}
outb (0x440,17);
outw (0x442,random () & 0x7fff);
for (i=1;i<256;i++)
p[i]=(rand () & 0x7fff);
r=(r+1) % 768;
EGB_writepage (1);
EGB_put (r-255,0,r+256-256,0,&p[0]);
EGB_put (r-255,1,r+256-256,1,&p[0]);
EGB_put (r-255,256,r+256-256,256,&p[0]);
EGB_put (r-255,256+1,r+256-256,256+1,&p[0]);
EGB_writepage (0);
EGB_writecolor ((random () & 0x7fff) & (1024*7+32*7+7));
for (i=0;i<16;i++)
EGB_pset (random () % 256,random () % 512);
}
SPR_display (0,1024);
EGB_writepage (0);
EGB_cls ();
EGB_writepage (1);
EGB_cls ();
VGA400_init ();
/* make new screen mode (640*256 / 256 colors) */
outb (0x440,0x0d);
outw (0x442,0x46+offset_line);
outb (0x440,0x0e);
outw (0x442,0x46+512+offset_line);
outb (0x440,0x0f);
outw (0x442,0x46+offset_line);
outb (0x440,0x10);
outw (0x442,0x46+512+offset_line);
for (i=0;i<256;i++)
EGB_palette (0,i,0x32,i/5,i);
EGB_palette (0,255,255,255,255);
cs=0; /* normal mode */
fs=639;
}